//
//  BaseViewController.m
//  嗨文
//
//  Created by 响当当 on 2019/1/7.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "BaseViewController.h"
#import "LoginFailedView.h"
#import "RealTimeViewController.h"
#import "HWUpdateAppView.h"

@interface BaseViewController ()
//默认返回按钮
@property (nonatomic, strong) UIButton *backBtn;

@property (nonatomic, assign) BOOL isStatusBarNormal;

@property (nonatomic, strong)LoginFailedView *loginFailedView;//提示

@property (nonatomic, strong)UIView *footView;

@property (nonatomic, assign) BOOL isFirstGetMessage;

@property (nonatomic, strong)NSDictionary *userInfo;

@property (nonatomic, strong)HWUpdateAppView *updateView;

@property (nonatomic, strong)NSString *nowTimeStr;

@end

@implementation BaseViewController

#pragma mark Init && Add
- (NSDictionary *)userInfo
{
    if (!_userInfo)
    {
        _userInfo = [[NSDictionary alloc]init];
    }
    return _userInfo;
}

- (HWUpdateAppView *)updateView
{
    if (!_updateView)
    {
        _updateView = [[HWUpdateAppView alloc]initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)];
    }
    return _updateView;
}

- (UIImageView *)line
{
    if (!_line) {
        _line = [[UIImageView alloc] initWithFrame:CGRectMake(0, NAVIBAR_HEIGHT-0.5, SCREEN_WIDTH, 0.5)];
        _line.backgroundColor = [UIColor grayColor];
    }
    return _line;
}

- (UIButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [_backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateHighlighted];
        [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
        _backBtn.frame = CGRectMake(5, NAVIBAR_HEIGHT - 44, 44, 44);
        _backBtn.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _backBtn;
}

- (UIButton *)leftButton
{
    if (!_leftButton) {
        _leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftButton.frame = CGRectMake(5, NAVIBAR_HEIGHT - 44, 44, 44);
        _leftButton.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _leftButton;
}

- (UIButton *)rightButton
{
    if (!_rightButton) {
        _rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightButton.frame = CGRectMake(SCREEN_WIDTH - 5 - 44, NAVIBAR_HEIGHT - 44, 44, 44);
        _rightButton.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _rightButton;
}

- (UIImageView *)topTitleView
{
    if (!_topTitleView) {
        _topTitleView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NAVIBAR_HEIGHT)];
        _topTitleView.backgroundColor = JSAMainColor;
        _topTitleView.userInteractionEnabled = YES;
        [self.view addSubview:_topTitleView];
    }
    return _topTitleView;
}

- (UIImageView *)navBgImageView
{
    if (!_navBgImageView) {
        _navBgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NAVIBAR_HEIGHT)];
        _navBgImageView.backgroundColor = [UIColor clearColor];
        _navBgImageView.userInteractionEnabled = YES;
    }
    return _navBgImageView;
}

- (UIImageView *)iconImgView
{
    if (!_iconImgView) {
        _iconImgView = [[UIImageView alloc] init];
        _iconImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _iconImgView;
}

- (UILabel *)topTitleLabel
{
    if (!_topTitleLabel)
    {
        _topTitleLabel = [[UILabel alloc] init];
        _topTitleLabel.textAlignment = NSTextAlignmentCenter;
        _topTitleLabel.textColor = [UIColor whiteColor];
        _topTitleLabel.backgroundColor = [UIColor clearColor];
        _topTitleLabel.font = kMainTitleFont;
        _topTitleLabel.frame = CGRectMake((SCREEN_WIDTH - 200)/2, NAVIBAR_HEIGHT - 44, 200, 44);
    }
    return _topTitleLabel;
}

- (UIButton *)secondLeftButton
{
    if (!_secondLeftButton) {
        _secondLeftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _secondLeftButton.frame = CGRectMake(5+44, NAVIBAR_HEIGHT - 44, 44, 44);
        _secondLeftButton.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _secondLeftButton;
}

- (UIButton *)secondRightButton
{
    if (!_secondRightButton) {
        _secondRightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _secondRightButton.frame = CGRectMake(SCREEN_WIDTH - 5 - 44 - 44, NAVIBAR_HEIGHT - 44, 44, 44);
        _secondRightButton.imageEdgeInsets = UIEdgeInsetsMake(0,15,0,0);
    }
    return _secondRightButton;
}

- (UILabel *)leftLabel
{
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_leftButton.frame)+5, NAVIBAR_HEIGHT - 44, CGRectGetMinX(_topTitleLabel.frame)- CGRectGetMaxX(_leftButton.frame)-5, 44)];
        _leftLabel.textColor = [UIColor whiteColor];
        _leftLabel.backgroundColor = [UIColor clearColor];
        _leftLabel.font = kDescTitleFont;
    }
    return _leftLabel;
}

- (UIView *)footView
{
    if (!_footView)
    {
        _footView = [[UIView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-TABBAR_HEIGHT-40*kUIScaleBasePlus,SCREEN_WIDTH,40*kUIScaleBasePlus)];
        _footView.backgroundColor = LCHexColor(0xFFF2E8);
        
        UIButton *btn = [Utilties creatButtonWithFrame:CGRectMake(0,0,SCREEN_WIDTH,40*kUIScaleBasePlus)
                                          textAligment:UIControlContentHorizontalAlignmentCenter
                                                  text:@"我也想用AI导购天眼  点击申请"
                                              textClor:LCHexColor(0xFFFFFF)
                                             buttonBGC:LCHexColor(0xFF7A17)
                                              textFont:14*kUIScaleBasePlus
                                                target:self
                                                method:@selector(openCp)];
        [_footView addSubview:btn];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2+40*kUIScaleBasePlus,30*kUIScaleBasePlus,55*kUIScaleBasePlus,1*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xFFFFFF);
        [_footView addSubview:lineView];
        
    }
    return _footView;
}

- (LoginFailedView *)loginFailedView
{
    if (!_loginFailedView)
    {
        _loginFailedView = [[LoginFailedView alloc]initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)];
    }
    return _loginFailedView;
}


- (UIButton *)headBtn
{
    if (!_headBtn)
    {
        _headBtn = [Utilties creatButtonWithFrame:CGRectMake(0,NAVIBAR_HEIGHT,SCREEN_WIDTH,40*kUIScaleBasePlus)
                                          textAligment:UIControlContentHorizontalAlignmentCenter
                                                  text:@"新客户来了，点击【实时】查看"
                                              textClor:LCHexColor(0xFF7A17)
                                             buttonBGC:LCHexColor(0xFFF2E8)
                                              textFont:14*kUIScaleBasePlus
                                                target:self
                                                method:@selector(gotoRealTime)];
    }
    return _headBtn;
}

- (UILabel *)reportTitleLabel
{
    if (!_reportTitleLabel)
    {
        _reportTitleLabel = [[UILabel alloc] init];
        _reportTitleLabel.textAlignment = NSTextAlignmentCenter;
        _reportTitleLabel.textColor = [UIColor whiteColor];
        _reportTitleLabel.backgroundColor = [UIColor clearColor];
        _reportTitleLabel.font = kMainTitleFont;
        _reportTitleLabel.frame = CGRectMake((SCREEN_WIDTH - 36*kUIScaleBasePlus)/2, NAVIBAR_HEIGHT - 34*kUIScaleBasePlus, 36*kUIScaleBasePlus, 17*kUIScaleBasePlus);
    }
    return _reportTitleLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textAlignment = NSTextAlignmentCenter;
        _timeLabel.textColor = [UIColor whiteColor];
        _timeLabel.backgroundColor = [UIColor clearColor];
        _timeLabel.font = [UIFont systemFontOfSize:10];
        _timeLabel.frame = CGRectMake((SCREEN_WIDTH - 60*kUIScaleBasePlus)/2,CGRectGetMaxY(self.reportTitleLabel.frame)+4.5*kUIScaleBasePlus, 60*kUIScaleBasePlus, 8*kUIScaleBasePlus);
    }
    return _timeLabel;
}

- (UIButton *)upTimeButton
{
    if (!_upTimeButton)
    {
        _upTimeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_upTimeButton setImage:[UIImage imageNamed:@"day_pre"] forState:UIControlStateNormal];
//        [_upTimeButton addTarget:self action:@selector(upDay) forControlEvents:UIControlEventTouchUpInside];
        _upTimeButton.frame = CGRectMake(120*kUIScaleBasePlus, NAVIBAR_HEIGHT - 44, 44, 44);
        _upTimeButton.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _upTimeButton;
}

- (UIButton *)nextTimeButton
{
    if (!_nextTimeButton)
    {
        _nextTimeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_nextTimeButton setImage:[UIImage imageNamed:@"day_next"] forState:UIControlStateNormal];
//        [_nextTimeButton addTarget:self action:@selector(nextDay) forControlEvents:UIControlEventTouchUpInside];
        _nextTimeButton.frame = CGRectMake(210*kUIScaleBasePlus, NAVIBAR_HEIGHT - 44, 44, 44);
        _nextTimeButton.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _nextTimeButton;
}

#pragma mark System Action
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = JSAMainBgColor;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeStatusBarFrame) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
    [self changeStatusBarFrame];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"RECEIVECUSTOMERS" object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"REPORTCUSTOMERS" object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"MYCUSTOMERS" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateVerson:) name:@"UPDATEVERSON" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showRealTime:) name:@"REALTIMECUSTOMERS" object:nil];

    
//    self.isFirstGetMessage = YES;
    
}


- (void)openCp
{
    NSDictionary *pramaters = @{
                                };
    
    WeakSelf(self)
    [infoManager openCustomer:pramaters sucess:^(id  _Nonnull acceptData) {
        NSDictionary *dic = acceptData[@"data"];
        LoginModel *model = [[LoginModel alloc]init];
        model.wx = dic[@"wx"];
        model.message = dic[@"message"];
        model.image = @"tishi";
        model.title = @"提示";
        
        AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        
        [delegate.window addSubview:self.loginFailedView];
        
        weakSelf.loginFailedView.model = model;
    } fail:^(NSError * _Nullable error) {
        
    }];
}

- (void)updateVerson:(NSNotification *)notfi
{
    NSDictionary *dic = notfi.userInfo;
    
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    
    
    UpdateModel *model = [[UpdateModel alloc]init];
    model.detail = dic[@"detail"];
    model.isNew = dic[@"isNew"];
    self.updateView.model = model;
    
    NSString *isFirstGetMessage = LCUserDefaultsGet(@"updateVersonCount");

    if (isFirstGetMessage.integerValue == 0 && ![current_User.detail isEqualToString:@""])
    {
        WeakSelf(self)
        self.updateView.cacnelViewBlock = ^{
            [[NSNotificationCenter defaultCenter] removeObserver:weakSelf name:@"UPDATEVERSON" object:nil];
            
            [[NSNotificationCenter defaultCenter] addObserver:weakSelf selector:@selector(updateVerson:) name:@"UPDATEVERSON" object:nil];
        };
        
        LCUserDefaultsSet(@"1", @"updateVersonCount");
        LCUserDefaultsSyn;
        
        [delegate.window addSubview:self.updateView];

        
    }
    
   
}

- (void)showService:(NSNotification *)notfi
{
    NSDictionary *dic = notfi.userInfo;
    self.userInfo = dic;
    NSString *isFirstGetMessage = LCUserDefaultsGet(@"notificationCount");
    
    if (![[Utilties getCurrentVC] isKindOfClass:[RealTimeViewController class]] && current_User.hasLogin.integerValue == 1 && isFirstGetMessage.integerValue == 1)
    {
        NSString *title = dic[@"aps"][@"alert"][@"title"];
        
        AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        
        [delegate.window addSubview:self.headBtn];
        
        [self.headBtn setTitle:title forState:UIControlStateNormal];
        
        LCUserDefaultsSet(@"0", @"notificationCount");
        LCUserDefaultsSyn;
        
        WeakSelf(self)
        [timeDevice createTimerWith:@"5" Sucess:^(id  _Nonnull acceptData) {
            
            NSString *str = acceptData;
            if (str.integerValue == 1)
            {
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [weakSelf.headBtn removeFromSuperview];
                    LCUserDefaultsSet(@"1", @"notificationCount");
                    LCUserDefaultsSyn;
                });
            }
        }];
    }
    
}

- (void)gotoRealTime
{
    [timeDevice timeStop];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"RECEIVECUSTOMERS" object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"REPORTCUSTOMERS" object:nil];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"MYCUSTOMERS" object:nil];

    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"RECEIVECUSTOMERS" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"REPORTCUSTOMERS" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showService:) name:@"MYCUSTOMERS" object:nil];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"RefreshLabel" object:nil userInfo:self.userInfo];

    [self.headBtn removeFromSuperview];
    
    LCUserDefaultsSet(@"1", @"notificationCount");
    LCUserDefaultsSyn;
    
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate gotoHome];
    
}

- (void)showRealTime:(NSNotification *)notfi
{

  
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController setNavigationBarHidden:YES];
    
    
    if (current_User.isDemoUser.integerValue == 1 && current_User.hasLogin.integerValue == 1 && self.viewType == 0 )
    {
        
        AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        
        NSString *isFirstGetMessage = LCUserDefaultsGet(@"updateVersonCount");

        if ([current_User.detail isEqualToString:@""] && isFirstGetMessage.integerValue == 0)
        {
            [delegate.window addSubview:self.footView];
        }
        else
        {
            if (self.footView)
            {
                [self.footView removeFromSuperview];
            }
        }
    }
    
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    if (!self.disablePopGesture)
    {
        BaseViewController *weakSelf = self;
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])
        {
            self.navigationController.interactivePopGestureRecognizer.delegate = weakSelf;
        }
    }

}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.footView removeFromSuperview];

}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer
{
    return !self.disablePopGesture;
}

- (void)changeStatusBarFrame
{
    int height = SCREEN_HEIGHT;
    [self.view setHeight:height];
    
    for (UIView *view in self.view.subviews) {
        if ([view isKindOfClass:[UIScrollView class]] && view.height == (SCREEN_HEIGHT - 20))
        {
            [view setHeight:height];
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)dealloc
{
    NSString *str = [NSString stringWithFormat:@"%@ dealloc",[NSString stringWithUTF8String:object_getClassName(self)]];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark Other Action
- (void)backAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

//默认绿色返回按钮
- (void)setDefaultNav
{
    [self.topTitleView addSubview:self.backBtn];
}

//删除返回按钮
- (void)cancelBackBtn
{
    [self.backBtn removeFromSuperview];
}

//默认绿色返回按钮/标题
- (void)setDefaultNavWithTitle:(NSString *)title
{
    [self setDefaultNav];
    [self setTitle:title];
}

//默认绿色返回按钮／标题／右侧按钮
- (void)setDefaultNavWithTitle:(NSString *)title WithRightButton:(UIImage *)rightImage
{
    [self setDefaultNavWithTitle:title];
    [self setRightButtonImage:rightImage];
}

//默认绿色返回按钮／右侧按钮
- (void)setDefaultNavWithRightButton:(UIImage *)rightImage
{
    [self setDefaultNavWithTitle:nil WithRightButton:rightImage];
}

//左侧按钮／右侧按钮
- (void)setLeftButton:(UIImage *)leftImage WithRightButton:(UIImage *)rightImage
{
    [self setLeftButton:leftImage WithTitle:nil WithRightButton:rightImage];
}

//左侧按钮／标题／右侧按钮
- (void)setLeftButton:(UIImage *)leftImage WithTitle:(NSString *)title WithRightButton:(UIImage *)rightImage
{
    [self setTitle:title];
    [self setLeftButtonImage:leftImage];
    [self setRightButtonImage:rightImage];
}


//左侧标题／标题／右侧标题
- (void)setLeftTitle:(NSString *)leftTitle WithTitle:(NSString *)title WithRightTitle:(NSString *)rightTitle
{
    [self setTitle:title];
    [self setLeftTitle:leftTitle];
    [self setRightTitle:rightTitle];
}

//左侧标题
- (void)setLeftTitle:(NSString *)leftTitle
{
    [self.leftButton setTitle:leftTitle forState:UIControlStateNormal];
    [self.leftButton setTitle:leftTitle forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.leftButton];
}
//右侧标题
- (void)setRightTitle:(NSString *)rightTitle
{
    [self.rightButton setTitle:rightTitle forState:UIControlStateNormal];
    [self.rightButton setTitle:rightTitle forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.rightButton];
}

//左侧按钮
- (void)setLeftButtonImage:(UIImage *)image
{
    [self.leftButton setImage:image forState:UIControlStateNormal];
    [self.leftButton setImage:image forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.leftButton];
}

//右侧按钮
- (void)setRightButtonImage:(UIImage *)image
{
    [self.rightButton setImage:image forState:UIControlStateNormal];
    [self.rightButton setImage:image forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.rightButton];
}

//标题
- (void)setTitle:(NSString *)title
{
    [self.topTitleView addSubview:self.topTitleLabel];
    self.topTitleLabel.text = title;
}

//右按钮标题
- (void)setRightTitle:(NSString *)title TitleColor:(UIColor *)titleColor
{
    [self.topTitleView addSubview:self.rightButton];
    [self.rightButton setTitle:title forState:UIControlStateNormal];
    [self.rightButton setTitleColor:titleColor forState:UIControlStateNormal];
    self.rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
}

//nav背景颜色
- (void)setNavBackgroundColor:(UIColor *)color
{
    self.topTitleView.backgroundColor = color;
}

//nav透明
- (void)setNavBackgroundClear
{
    self.topTitleView.backgroundColor = [UIColor clearColor];
}

//nav背景图片
- (void)setNavBackgroundImage:(UIImage *)bgImage
{
    [self setNavBackgroundClear];
    self.navBgImageView.image = bgImage;
    [self.topTitleView addSubview:self.navBgImageView];
    [self.topTitleView sendSubviewToBack:self.navBgImageView];
}

//左侧第二按钮
- (void)setSecondLeftButtonImage:(UIImage *)image
{
    [self.secondLeftButton setImage:image forState:UIControlStateNormal];
    [self.secondLeftButton setImage:image forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.secondLeftButton];
}

//右侧第二按钮
- (void)setSecondRightButtonImage:(UIImage *)image
{
    [self.secondRightButton setImage:image forState:UIControlStateNormal];
    [self.secondRightButton setImage:image forState:UIControlStateHighlighted];
    [self.topTitleView addSubview:self.secondRightButton];
}

//左侧第一Label
- (void)setLeftLabelText:(NSString *)info
{
    self.leftLabel.text = info;
    [self.topTitleView addSubview:self.leftLabel];
}

//底部横线
- (void)setBottomLine
{
    [self.topTitleView addSubview:self.line];
}

- (void)seticonImgView:(UIImage *)icon
{
    [self.topTitleView addSubview:self.iconImgView];
    self.iconImgView.image = icon;
}


//报告无返回按钮/标题
- (void)setReportNavWithTitle:(NSString *)title
{
    [self.topTitleView addSubview:self.reportTitleLabel];
    [self.topTitleView addSubview:self.timeLabel];
    [self.topTitleView addSubview:self.upTimeButton];
    [self.topTitleView addSubview:self.nextTimeButton];
    self.reportTitleLabel.text = title;
    self.nowTimeStr = [Utilties getLastday:[Utilties dateFromString:[Utilties getYearAndMonth]]];
    self.timeLabel.text = self.nowTimeStr;
}

- (void)refrshDay
{
    if (self.timeLabel)
    {
        self.nowTimeStr = [Utilties getLastday:[Utilties dateFromString:[Utilties getYearAndMonth]]];
        self.timeLabel.text = self.nowTimeStr;
    }
}

@end
